package org.bizming.medicine.service;

import java.util.List;

import org.bizming.base.BaseErrCode;
import org.bizming.base.BaseException;
import org.bizming.medicine.dao.MedicineUnitDao;
import org.bizming.medicine.model.help.ActionType;
import org.bizming.medicine.model.help.MedicineUnit;

public class MedicineUnitServiceImpl implements MedicineUnitService {

	private MedicineUnitDao unitDao;

	@Override
	public boolean add(MedicineUnit t) throws BaseException {
		if (!t.isValidate(ActionType.ADD)) {
			throw new BaseException(BaseErrCode.INVALIDATE);
		}
		return unitDao.add(t);
	}

	@Override
	public boolean update(MedicineUnit t) throws BaseException {
		if (!t.isValidate(ActionType.UPDATE)) {
			throw new BaseException(BaseErrCode.INVALIDATE);
		}
		return unitDao.update(t);
	}

	@Override
	public MedicineUnit get(int id) {
		return unitDao.get(id);
	}

	@Override
	public boolean remove(int id) {
		return unitDao.remove(id);
	}

	@Override
	public List<MedicineUnit> selectList() {
		return unitDao.selectList();
	}

	// ==============================
	public MedicineUnitDao getUnitDao() {
		return unitDao;
	}

	public void setUnitDao(MedicineUnitDao unitDao) {
		this.unitDao = unitDao;
	}

}
